// **********************************************************************
//
// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

// Ice version 3.3.0

package CustomerRelationsManagement;

/**
 *
 * @author Administrator
 */
public final class _CRMDelM extends Ice._ObjectDelM implements _CRMDel
{
    /**
     *
     * @param __ctx
     * @return
     * @throws IceInternal.LocalExceptionWrapper
     */
    public customerPrx
    CreateCustomer(java.util.Map<String, String> __ctx)
        throws IceInternal.LocalExceptionWrapper
    {
        IceInternal.Outgoing __og = __handler.getOutgoing("CreateCustomer", Ice.OperationMode.Normal, __ctx);
        try
        {
            boolean __ok = __og.invoke();
            try
            {
                if(!__ok)
                {
                    try
                    {
                        __og.throwUserException();
                    }
                    catch(Ice.UserException __ex)
                    {
                        throw new Ice.UnknownUserException(__ex.ice_name());
                    }
                }
                IceInternal.BasicStream __is = __og.is();
                __is.startReadEncaps();
                customerPrx __ret;
                __ret = customerPrxHelper.__read(__is);
                __is.endReadEncaps();
                return __ret;
            }
            catch(Ice.LocalException __ex)
            {
                throw new IceInternal.LocalExceptionWrapper(__ex, false);
            }
        }
        finally
        {
            __handler.reclaimOutgoing(__og);
        }
    }

    /**
     *
     * @param __ctx
     * @return
     * @throws IceInternal.LocalExceptionWrapper
     */
    public orderPrx
    CreateOrder(java.util.Map<String, String> __ctx)
        throws IceInternal.LocalExceptionWrapper
    {
        IceInternal.Outgoing __og = __handler.getOutgoing("CreateOrder", Ice.OperationMode.Normal, __ctx);
        try
        {
            boolean __ok = __og.invoke();
            try
            {
                if(!__ok)
                {
                    try
                    {
                        __og.throwUserException();
                    }
                    catch(Ice.UserException __ex)
                    {
                        throw new Ice.UnknownUserException(__ex.ice_name());
                    }
                }
                IceInternal.BasicStream __is = __og.is();
                __is.startReadEncaps();
                orderPrx __ret;
                __ret = orderPrxHelper.__read(__is);
                __is.endReadEncaps();
                return __ret;
            }
            catch(Ice.LocalException __ex)
            {
                throw new IceInternal.LocalExceptionWrapper(__ex, false);
            }
        }
        finally
        {
            __handler.reclaimOutgoing(__og);
        }
    }

    /**
     *
     * @param CustId
     * @param __ctx
     * @return
     * @throws IceInternal.LocalExceptionWrapper
     * @throws CustomerRelationsManagement.DBError
     */
    public customerPrx
    LoadCustomerById(int CustId, java.util.Map<String, String> __ctx)
        throws IceInternal.LocalExceptionWrapper,
               DBError
    {
        IceInternal.Outgoing __og = __handler.getOutgoing("LoadCustomerById", Ice.OperationMode.Normal, __ctx);
        try
        {
            try
            {
                IceInternal.BasicStream __os = __og.os();
                __os.writeInt(CustId);
            }
            catch(Ice.LocalException __ex)
            {
                __og.abort(__ex);
            }
            boolean __ok = __og.invoke();
            try
            {
                if(!__ok)
                {
                    try
                    {
                        __og.throwUserException();
                    }
                    catch(DBError __ex)
                    {
                        throw __ex;
                    }
                    catch(Ice.UserException __ex)
                    {
                        throw new Ice.UnknownUserException(__ex.ice_name());
                    }
                }
                IceInternal.BasicStream __is = __og.is();
                __is.startReadEncaps();
                customerPrx __ret;
                __ret = customerPrxHelper.__read(__is);
                __is.endReadEncaps();
                return __ret;
            }
            catch(Ice.LocalException __ex)
            {
                throw new IceInternal.LocalExceptionWrapper(__ex, false);
            }
        }
        finally
        {
            __handler.reclaimOutgoing(__og);
        }
    }

    /**
     *
     * @param CustName
     * @param __ctx
     * @return
     * @throws IceInternal.LocalExceptionWrapper
     * @throws CustomerRelationsManagement.DBError
     * @throws CustomerRelationsManagement.RecordNotFound
     */
    public customerPrx
    LoadCustomerByName(String CustName, java.util.Map<String, String> __ctx)
        throws IceInternal.LocalExceptionWrapper,
               DBError,
               RecordNotFound
    {
        IceInternal.Outgoing __og = __handler.getOutgoing("LoadCustomerByName", Ice.OperationMode.Normal, __ctx);
        try
        {
            try
            {
                IceInternal.BasicStream __os = __og.os();
                __os.writeString(CustName);
            }
            catch(Ice.LocalException __ex)
            {
                __og.abort(__ex);
            }
            boolean __ok = __og.invoke();
            try
            {
                if(!__ok)
                {
                    try
                    {
                        __og.throwUserException();
                    }
                    catch(DBError __ex)
                    {
                        throw __ex;
                    }
                    catch(RecordNotFound __ex)
                    {
                        throw __ex;
                    }
                    catch(Ice.UserException __ex)
                    {
                        throw new Ice.UnknownUserException(__ex.ice_name());
                    }
                }
                IceInternal.BasicStream __is = __og.is();
                __is.startReadEncaps();
                customerPrx __ret;
                __ret = customerPrxHelper.__read(__is);
                __is.endReadEncaps();
                return __ret;
            }
            catch(Ice.LocalException __ex)
            {
                throw new IceInternal.LocalExceptionWrapper(__ex, false);
            }
        }
        finally
        {
            __handler.reclaimOutgoing(__og);
        }
    }

    /**
     *
     * @param __ctx
     * @return
     * @throws IceInternal.LocalExceptionWrapper
     * @throws CustomerRelationsManagement.DBError
     * @throws CustomerRelationsManagement.RecordNotFound
     */
    public orderPrx[]
    LoadNewOrders(java.util.Map<String, String> __ctx)
        throws IceInternal.LocalExceptionWrapper,
               DBError,
               RecordNotFound
    {
        IceInternal.Outgoing __og = __handler.getOutgoing("LoadNewOrders", Ice.OperationMode.Normal, __ctx);
        try
        {
            boolean __ok = __og.invoke();
            try
            {
                if(!__ok)
                {
                    try
                    {
                        __og.throwUserException();
                    }
                    catch(DBError __ex)
                    {
                        throw __ex;
                    }
                    catch(RecordNotFound __ex)
                    {
                        throw __ex;
                    }
                    catch(Ice.UserException __ex)
                    {
                        throw new Ice.UnknownUserException(__ex.ice_name());
                    }
                }
                IceInternal.BasicStream __is = __og.is();
                __is.startReadEncaps();
                orderPrx[] __ret;
                __ret = OrderListHelper.read(__is);
                __is.endReadEncaps();
                return __ret;
            }
            catch(Ice.LocalException __ex)
            {
                throw new IceInternal.LocalExceptionWrapper(__ex, false);
            }
        }
        finally
        {
            __handler.reclaimOutgoing(__og);
        }
    }

    /**
     *
     * @param CustId
     * @param __ctx
     * @return
     * @throws IceInternal.LocalExceptionWrapper
     * @throws CustomerRelationsManagement.DBError
     */
    public orderPrx[]
    LoadOrderByCustomer(int CustId, java.util.Map<String, String> __ctx)
        throws IceInternal.LocalExceptionWrapper,
               DBError
    {
        IceInternal.Outgoing __og = __handler.getOutgoing("LoadOrderByCustomer", Ice.OperationMode.Normal, __ctx);
        try
        {
            try
            {
                IceInternal.BasicStream __os = __og.os();
                __os.writeInt(CustId);
            }
            catch(Ice.LocalException __ex)
            {
                __og.abort(__ex);
            }
            boolean __ok = __og.invoke();
            try
            {
                if(!__ok)
                {
                    try
                    {
                        __og.throwUserException();
                    }
                    catch(DBError __ex)
                    {
                        throw __ex;
                    }
                    catch(Ice.UserException __ex)
                    {
                        throw new Ice.UnknownUserException(__ex.ice_name());
                    }
                }
                IceInternal.BasicStream __is = __og.is();
                __is.startReadEncaps();
                orderPrx[] __ret;
                __ret = OrderListHelper.read(__is);
                __is.endReadEncaps();
                return __ret;
            }
            catch(Ice.LocalException __ex)
            {
                throw new IceInternal.LocalExceptionWrapper(__ex, false);
            }
        }
        finally
        {
            __handler.reclaimOutgoing(__og);
        }
    }

    /**
     *
     * @param OrderId
     * @param __ctx
     * @return
     * @throws IceInternal.LocalExceptionWrapper
     * @throws CustomerRelationsManagement.DBError
     * @throws CustomerRelationsManagement.RecordNotFound
     */
    public orderPrx
    LoadOrderById(int OrderId, java.util.Map<String, String> __ctx)
        throws IceInternal.LocalExceptionWrapper,
               DBError,
               RecordNotFound
    {
        IceInternal.Outgoing __og = __handler.getOutgoing("LoadOrderById", Ice.OperationMode.Normal, __ctx);
        try
        {
            try
            {
                IceInternal.BasicStream __os = __og.os();
                __os.writeInt(OrderId);
            }
            catch(Ice.LocalException __ex)
            {
                __og.abort(__ex);
            }
            boolean __ok = __og.invoke();
            try
            {
                if(!__ok)
                {
                    try
                    {
                        __og.throwUserException();
                    }
                    catch(DBError __ex)
                    {
                        throw __ex;
                    }
                    catch(RecordNotFound __ex)
                    {
                        throw __ex;
                    }
                    catch(Ice.UserException __ex)
                    {
                        throw new Ice.UnknownUserException(__ex.ice_name());
                    }
                }
                IceInternal.BasicStream __is = __og.is();
                __is.startReadEncaps();
                orderPrx __ret;
                __ret = orderPrxHelper.__read(__is);
                __is.endReadEncaps();
                return __ret;
            }
            catch(Ice.LocalException __ex)
            {
                throw new IceInternal.LocalExceptionWrapper(__ex, false);
            }
        }
        finally
        {
            __handler.reclaimOutgoing(__og);
        }
    }
}
